//
//  DBJIllTypeTabViewController.m
//  DBJ
//
//  Created by Captain_czq on 16/11/15.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJIllTypeTabViewController.h"

@interface DBJIllTypeTabViewController ()

/* 数据数组 */
@property(nonatomic,strong)NSArray *plist;

@end

@implementation DBJIllTypeTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
 
}
//设置ui
-(void)dbjSetupSubviews{
    
    [super dbjSetupSubviews];
    //获取数据
    self.plist=[self loadPlist];
    //刷新数据
    [self.tableView reloadData];
    
}
/* 获取数据 */
-(NSArray *)loadPlist{
    NSURL *url=[[NSBundle mainBundle]URLForResource:@"illType.plist" withExtension:nil];
    NSArray *arry=[NSArray arrayWithContentsOfURL:url];
    return arry;
}


#pragma mark -实现数据源方法
/* 返回行 */
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.plist.count;
}

/* 返回单元格 */
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"typeCell"];
    if(!cell){
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"typeCell"];
        //设置文本...
        cell.textLabel.text=self.plist[indexPath.row];
        cell.textLabel.font=[UIFont systemFontOfSize:14];
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
     
    }
    
    return cell;  //返回cell
}
#pragma mark -实现代理方法

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //实现代理方法回调cell.textlabel
    //获取cell
    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
    if([self.delegate respondsToSelector:@selector(sendIlltype:WithType:index:)]){
       
        [self.delegate sendIlltype:self WithType:cell.textLabel.text index:indexPath.row];
    }
     [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
